Why @property?
如果对于一个类,我们希望用getter和setter来控制成员变量的赋值和取值,又不希望对于每一个成员变量都显式的写出getter和setter, 就可以用@property
1 | class Student: |
When calling
1 | Student().score # get_score |
More details about the func property
here
积极勤奋,主动勇敢
如果对于一个类,我们希望用getter和setter来控制成员变量的赋值和取值,又不希望对于每一个成员变量都显式的写出getter和setter, 就可以用@property
1 | class Student: |
When calling
1 | Student().score # get_score |
More details about the func property
here